package com.prs.crm.service.hr.impl;

import java.util.List;

import com.prs.crm.dao.hr.SalaryDao;
import com.prs.crm.domain.hr.Salary;
import com.prs.crm.domain.hr.SalaryRelat;
import com.prs.crm.service.hr.SalaryItemService;
import com.prs.crm.service.hr.SalaryRelatService;
import com.prs.crm.service.hr.SalaryService;
import com.prs.crm.service.impl.BaseServiceImpl;

public class SalaryServiceImpl extends BaseServiceImpl<Salary, SalaryDao>
		implements SalaryService {
	private SalaryRelatService salaryRelatService;
	private SalaryItemService salaryItemService;

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.prs.crm.service.hr.SalaryService#saveSalary(com.prs.crm.domain.hr
	 * .Salary, java.lang.Integer[], java.lang.Double[])
	 */
	@Override
	public void saveSalary(Salary salary, Integer[] items, String[] num) {
		// TODO Auto-generated method stub
		int i = 0;
		salary.setState("2");
		this.getDao().save(salary);
		for (Integer itemid : items) {
			SalaryRelat relat = new SalaryRelat();
			relat.setSalary(salary);
			relat.setSalaryItem(salaryItemService.get(itemid));
			relat.setValue(Double.valueOf(num[i++]));

			salaryRelatService.save(relat);
		}
	}

	public SalaryRelatService getSalaryRelatService() {
		return salaryRelatService;
	}

	public void setSalaryRelatService(SalaryRelatService salaryRelatService) {
		this.salaryRelatService = salaryRelatService;
	}

	public SalaryItemService getSalaryItemService() {
		return salaryItemService;
	}

	public void setSalaryItemService(SalaryItemService salaryItemService) {
		this.salaryItemService = salaryItemService;
	}

	@Override
	public List<Salary> getAllSalary() {
		// TODO Auto-generated method stub
		return this.getDao().getAllSalary();
	}

	@Override
	public Double getTotalPayMoney(Salary salary) {
		// TODO Auto-generated method stub

		return null;
	}

}
